package com.yilin.medical.views;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yilin.medical.R;

public class ActTitle extends RelativeLayout {
	private ImageView back;
	private TextView title;
	private TextView titleTv;
	private ImageView titleIv;

	private Context mContext;

	public ActTitle(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.mContext = context;
	}

	public ActTitle(Context context) {
		super(context);
		this.mContext = context;
	}

	public ActTitle(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.mContext = context;
	}

	public void init(final Activity context) {

		back = (ImageView) context.findViewById(R.id.title_back);
		title = (TextView) context.findViewById(R.id.title);
		titleTv = (TextView) context.findViewById(R.id.title_tv);
		titleIv = (ImageView) context.findViewById(R.id.title_iv);
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// ToastUntil.showShortToast(context, "返回");
				context.finish();
			}
		});
	}

	public void setImageView(int id, int visibility, OnClickListener l) {
		titleIv.setImageResource(id);
		setImageView(visibility, l);
	}

	public void setImageView(int visibility, OnClickListener l) {
		titleIv.setVisibility(visibility);
		titleIv.setOnClickListener(l);
	}
	public void setTitleRight(String text,int visibility, OnClickListener l) {
		titleTv.setText(text);
		titleTv.setVisibility(visibility);
		titleTv.setOnClickListener(l);
	}

	public ImageView getBack() {
		return back;
	}

	public void setBack(ImageView back) {
		this.back = back;
	}

	public TextView getTitle() {
		return title;
	}

	public void setTitle(TextView title) {
		this.title = title;
	}

	public TextView getTitleTv() {
		return titleTv;
	}

	public void setTitleTv(TextView titleTv) {
		this.titleTv = titleTv;
	}

	public ImageView getTitleIv() {
		return titleIv;
	}

	public void setTitleIv(ImageView titleIv) {
		this.titleIv = titleIv;
	}

}
